from developer_module.rpc import developer_pb2_grpc
from common.api import http_result
from common.api.rpc_connect_pool import get_connect
from user_module.rpc import user_pb2_grpc, user_pb2
import json


class DeveloperHandler(developer_pb2_grpc.DeveloperServicer):

    def do_click_func(self, param, session):
        con_id, con = get_connect('user')
        # from user_module.rpc.rpc_proto import user_pb2_grpc, user_pb2
        # conn = grpc.insecure_channel(service_info['host'] + ':' + service_info['port'])
        client = user_pb2_grpc.UserStub(channel=con)
        response = client.logout(user_pb2.req(content=json.dumps(param)))

        print(response)
        return self.resp(1, http_result.RESULT_SUCCESS)
